<template>
  <div>
    <table-ext :columns="columns2" :searchForm="searchForm2" :config="config2" ref="tableExt2">
    </table-ext>
  </div>

</template>
<script>
  import TableExt from '@/components/common/table-ext/table-ext.vue';
  import SelectTree from '@/components/common/select-ext/select-tree.vue';
  import TableIcon from '@/components/common/table-ext/table-icon';
  export default {
    // 引入自定义表格组件
    components:{
      SelectTree,
      'table-ext': TableExt
    },
    data() {
      return {
        // 弹框属性
        addOrUpdateForm: {
          abolishReason: ''
        },
        // 弹框显示控制
        dialogFormVisible: false,
        // 修改弹框控制
        dialogUpdate: false,
        
        config2:{ // 页面共通配置
          title: '工厂考察评估明细', //页面标题
          isPage: true, //是否分页
          isNo: true, //是否显示序号
          align:'center',//表格居中
          selection: false, //是否显示复选框
          crudMapping:{ // CRUD方法
            query:{
              url: this.lib.config.host.vendorDlv+"/vendormgt/dlv/factoryInspect/factoryInspectMgt/queryItem",
              method: 'post'
            }
          }
        },
        
         // 查询表单配置
        searchForm2:[
        { // 查询表单配置
          label: '采购组织', 
          key: 'purOrgId', 
          type: 'select',
          dict:{
            url:this.lib.config.host.masterData + '/system/purOrgMgt/purOrg/getPurOrgByUserId/'+this.getCurrUserId(),
            method:'get',
            label:'purOrgName',
            value:'id'
          }
        }, {
          label: '采购组',
          key: 'purGroupId',
          type: 'select',
          dict:{
            url:this.lib.config.host.masterData + '/mdata/purOrgMgt/purGroup/getByPurOrgId/{purOrgId}',
            method:'post',
            label:'purGroupName',
            value:'id'
          }
        },{
          label: '单据号',
          key: 'inspectNo',
          type: 'input'
        },{
          label: '标题',
          key: 'title',
          type: 'input'
        },{
          label: '供应商编码',
          key: 'vendorCode',
          type: 'input'
        },{
          label: '供应商名称',
          key: 'vedorName',
          type: 'input',
        },{
          label: '结论',
          key: 'resultFlag',
          type: 'select',
          dict: [{
            key: '-1',
            value: '合格'
          },{
            key: '1',
            value: '不合格'
          }]
        },{
          label: '评估类型',
          key: 'inspectType',
          type: 'select',
          dict: [{
            key: '1',
            value: '初审'
          },{
            key: '2',
            value: '年度复审'
          }]
        }, {
          label: '验证状态',
          key: 'checkStatus',
          type: 'select',
          dict: [{
            key: '0',
            value: '未验证'
          }, {
            key: '1',
            value: '待验证'
          }, {
            key: '2',
            value: '验证通过'
          }, {
            key: '3',
            value: '验证驳回'
          }]
        },{
          label: '完成状态',
          key: 'completeStatus',
          type: 'select',
          dict: [{
            key: '0',
            value: '未完成'
          },{
            key: '1',
            value: '已完成'
          }]
        },{
          label: '反馈状态',
          key: 'feedbackStatus',
          type: 'select',
          dict: [{
            key: '0',
            value: '待反馈'
          }, {
            key: '1',
            value: '已反馈'
          }]
        }],
        
        columns2:[{ 
          label: '操作', // 表格header
          render:(createElement, params)=>{ // 动态渲染，click事件示例
            let _this = this;
            return createElement('div', {}, 
            [createElement('span', {}, '--')
            ]);
          }
        },{
          label: '采购组织', 
          key: 'factoryInspect.purOrgName',
          width:'160px'

        }, {
          label: '采购组',
          key: 'factoryInspect.purGroupName',
           width:'160px'
        },{
          label: '单据号',
          key: 'factoryInspect.inspectNo',
          width: '180',
          render: (createElement, params) => { // 动态渲染，click事件示例
            let _this = this;
              return createElement('div', {}, [createElement('a', {
                  style: {
                    color: '#409EFF',
                    cursor: 'pointer'
                  },
              on: {
                click() {
                  _this.setCurrent(params.row.factoryInspect.id);
                }
              }
            }, params.row.factoryInspect.inspectNo)]);
          }
        },{
          label: '标题',
          key: 'factoryInspect.title',
          width:'160'
        },{
          label: '评估类型',
          key: 'factoryInspect.inspectType',
          render: (createElement, params) => { //动态渲染, 字典表示例
            let inspectType = params.row.factoryInspect.inspectType;
            if (inspectType == 1) {
              return createElement('div', '初审');
            } else {
              return createElement('div', '年度复审');
            }
          }          
        },{
          label: '品类',
          key: 'factoryInspect.categoryName',
           width:'200px'
        },{
          label: '供应商编码',
          key: 'vendorCode',
          width:'120'
        },{
          label: '供应商名称',
          key: 'vendorName',
          width:'240'
        },{
          label: '评估分数',
          key: 'totalPoints'
        },{
          label: '结论',
          key: 'resultFlag'
        },{
          label: '整改标识',
          key: 'improveFlagStr',
          render:(createElement, params)=>{ //动态渲染, 字典表示例
            return createElement(TableIcon,{props:{
                flag: params.row.improveFlagStr,
                titles: [{status:0,title:'否'},{status:1,title:'是'}]
            }});
          }
        },{
          label: '反馈状态',
          key: 'feedbackStatus',
          render:(createElement, params)=>{ //动态渲染, 字典表示例
            return createElement(TableIcon,{props:{
                flag: params.row.feedbackStatus,
                titles: [{status:0,title:'未反馈'},{status:1,title:'已反馈'}]
            }});
          }
        },{
          label: '验证状态',
          key: 'checkStatus',
          render:(createElement, params)=>{ //动态渲染, 字典表示例
            return createElement(TableIcon,{props:{
                flag: params.row.checkStatus,
                titles: [{status:0,title:'未验证'},{status:1,title:'已验证'}]
            }});
          }
        },{
          label: '完成状态',
          key: 'completeStatus',
          render:(createElement, params)=>{ //动态渲染, 字典表示例
            return createElement(TableIcon,{props:{
                flag: params.row.completeStatus,
                titles: [{status:0,title:'未完成'},{status:1,title:'已完成'}]
            }});
          }
        }]
      };
    },
    mounted() {
    },
    methods: {
      addInspect(){
        this.$router.push('/Index/VendorDlv/VendorInspectAdd');
      },
      //点击编码 跳转到新页面
      setCurrent(id) {
        window.open('/FactoryInspectItem?id=' + id)
      }      
    }
  }
</script>
